<?
/*
 * Copyright 2004-2005 Sigve Indregard.
 *
 * This file is part of Laivsys.
 *
 * Laivsys is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Laivsys is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Laivsys; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/*
 * $Id: roller.php 6 2005-07-11 23:14:47Z say $
 */
 
include_once("db.php");
include_once("laivid.php");
include_once("design.php");
include("admin/rollerinclude.php");

$arr=getLaiv();
$laivid = $arr['ID'];

$sidetittel=$arr['Tittel']." - Rollebeskrivelser";
if ($_REQUEST['print']=='true') {
	?>
	<html>
	<head>
	<title><?=$sidetittel?></title>
	</head>
	<body>
	<?
} else {
	include("top.php");
}

if (time() > strtotime($arr['Roller_release'])) {
	$id = $_REQUEST['id'];
	if ($id != "") {
		if ($_REQUEST['print'] != 'true') {
			headline("Rollebeskrivelser");
			echo "<div class=\"text\">\n";
			echo "<p><a href=\"roller.php\">Tilbake til oversikten</a></p>";
			echo "<p><a href=\"roller.php?id=$id&amp;print=true\" target=\"print\">";
			echo "Utskriftsvennlig versjon</a>\n";
		}
		completeRollebeskrivelse($id, "roller.php?id=");
		echo "</div>";
	} else {
		headline("Rollebeskrivelser");
		text(listRoller($arr['ID']));
	}
} else {
	headline("Rollebeskrivelser");
	text("Disse blir ikke tilgjengelig f�r ".isodateformat($arr['Roller_release']).".");
}

if ($_REQUEST['print']=='true') {
	?>
	</body>
	</html>
	<?
} else {
	include ("bottom.php");
}

function listRoller($laiv) {
	$sql="SELECT * FROM r_Rolle WHERE LaivID=$laiv ORDER BY familienavn, rollenavn";
	$roller=mysql_query($sql) or die(mysql_error());
	$retur="";
	while ($rolle = mysql_fetch_assoc($roller)) {
		$retur.= "<a href=\"roller.php?id={$rolle['ID']}\">";
		$retur.= "&gt;&gt;&gt;</a>&nbsp;";
		$retur.= getRollenavn($rolle['rollekode']);
		$retur.= " ({$rolle['yrke']})\n";
	}
	return $retur;
}
?>
